<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Record extends Model
{
    //
    public function business()
    {
        return $this->belongsTo(Business::class, 'business_id');
    }

    public function department()
    {
        return $this->belongsTo(Department::class, 'department_id');
    }
    public function analyzer()
    {
        return $this->belongsTo(User::class,'analyzer_id');
    }
    public function users():BelongsToMany
    {
        $pivotTable = 'user_records';
        $relatedModel = User::class;
        return $this->belongsToMany($relatedModel, $pivotTable, 'record_id', 'user_id');
    }
}
